package otlex

import (
	"errors"
	"time"
)

type RetryConfig struct {
	// Enabled indicates whether to not retry sending batches in case of
	// export failure.
	Enabled bool `json:"enabled" toml:"enabled" yaml:"enabled" `
	// InitialInterval the time to wait after the first failure before
	// retrying.
	InitialInterval time.Duration `json:"initial_interval" toml:"initial_interval" yaml:"initial_interval" `
	// MaxInterval is the upper bound on backoff interval. Once this value is
	// reached the delay between consecutive retries will always be
	// `MaxInterval`.
	MaxInterval time.Duration `json:"max_interval" toml:"max_interval" yaml:"max_interval" `
	// MaxElapsedTime is the maximum amount of time (including retries) spent
	// trying to send a request/batch.  Once this value is reached, the data
	// is discarded.
	MaxElapsedTime time.Duration `json:"max_elapsed_time" toml:"max_elapsed_time" yaml:"max_elapsed_time" `
}
type ExporterConfig struct {
	Type     ProtocolType      `json:"type" toml:"type" yaml:"type" `
	Insecure bool              `json:"insecure" toml:"insecure" yaml:"insecure"`
	Headers  map[string]string `json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty"`
	Timeout  int               `json:"timeout" toml:"timeout" yaml:"timeout"`
	Retry    RetryConfig       `json:"retry,omitempty" toml:"retry,omitempty" yaml:"retry,omitempty"`
	TLS      TLS               `json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty"`

	// 设置 OTLP 收集器的 gRPC 端点:"localhost:4317"
	// 设置 OTLP 收集器的 HTTP 端点:"http://localhost:4318"
	Endpoint string `json:"endpoint" toml:"endpoint" yaml:"endpoint"`

	//http
	Compression bool   `json:"compression" toml:"compression" yaml:"compression"`
	URLPath     string `json:"urlpath" toml:"urlpath" yaml:"urlpath"`

	//grpc
	ReconnectionPeriod int    `json:"reconnection_period" toml:"reconnection_period" yaml:"reconnection_period"`
	ServiceConfig      string `json:"service_config" toml:"service_config" yaml:"service_config"`
}
type ExportHandle = func(config *ExporterConfig)

var NotFoundType = errors.New("NotFoundType")
